USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[TablesNames-Insert]    Script Date: [[20120714223942]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223942]]
-- Description:	Insert record into table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Insert]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[TablesNames](/*[TableName_RowNumber], [TableName_ID], [TableName_NameAr], [TableName_NameEn], [TableName_Search]*/)
	VALUES     (/*@TableName_RowNumber, @TableName_ID, @TableName_NameAr, @TableName_NameEn, @TableName_Search*/)

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[TablesNames-update]    Script Date: [[20120714223942]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223942]]
-- Description:	Update record in table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-update]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/**/
		Update [dbo].[TablesNames] SET 
		/*[TableName_RowNumber] =@TableName_RowNumber, 
		[TableName_ID] =@TableName_ID, 
		[TableName_NameAr] =@TableName_NameAr, 
		[TableName_NameEn] =@TableName_NameEn, 
		[TableName_Search] =@TableName_Search*/
		/*WHERE ([TableName_ID] = @TableName_ID)*/
	/**/

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[TablesNames-Insert-Update]    Script Date: [[20120714223942]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223942]]
-- Description:	Insert OR Update record into table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Insert-Update]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null  , 
	@Inserted bit OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[TablesNames] 
					/*WHERE ([TableName_ID] = @TableName_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[TablesNames](/*[TableName_RowNumber], [TableName_ID], [TableName_NameAr], [TableName_NameEn], [TableName_Search]*/)
		VALUES     (/*@TableName_RowNumber, @TableName_ID, @TableName_NameAr, @TableName_NameEn, @TableName_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/**/
			Update [dbo].[TablesNames] SET 
			/*[TableName_RowNumber] =@TableName_RowNumber, 
			[TableName_ID] =@TableName_ID, 
			[TableName_NameAr] =@TableName_NameAr, 
			[TableName_NameEn] =@TableName_NameEn, 
			[TableName_Search] =@TableName_Search*/
			/*WHERE ([TableName_ID] = @TableName_ID)*/
		/**/
		
		SET /*@*/Inserted=0
	END

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[TablesNames-Delete]    Script Date: [[20120714223942]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223942]]
-- Description:	delete records from table [dbo].[TablesNames] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Delete]
	/*@TableName_RowNumber int =null  , 
	@TableName_ID uniqueidentifier =null  , 
	@TableName_NameAr varchar(200) =null  , 
	@TableName_NameEn varchar(200) =null  , 
	@TableName_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[TablesNames]
	WHERE /*( [TableName_RowNumber] = ISNULL(@TableName_RowNumber, [TableName_RowNumber]) )
	AND ( [TableName_ID] = ISNULL(@TableName_ID, [TableName_ID]) )
	AND ( [TableName_NameAr] like ISNULL(@TableName_NameAr, [TableName_NameAr]) )
	AND ( [TableName_NameEn] like ISNULL(@TableName_NameEn, [TableName_NameEn]) )
	AND ( [TableName_Search] like ISNULL(@TableName_Search, [TableName_Search]) )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[TablesNames-Select]    Script Date: [[20120714223942]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223942]]
-- Description:	select records from table [dbo].[TablesNames] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Select]
	/*@TableName_RowNumber int =null  , 
	@TableName_ID uniqueidentifier =null  , 
	@TableName_NameAr varchar(200) =null  , 
	@TableName_NameEn varchar(200) =null  , 
	@TableName_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[TablesNames]
	WHERE /*( [TableName_RowNumber] = ISNULL(@TableName_RowNumber, [TableName_RowNumber]) )
	AND ( [TableName_ID] = ISNULL(@TableName_ID, [TableName_ID]) )
	AND ( [TableName_NameAr] like ISNULL(@TableName_NameAr, [TableName_NameAr]) )
	AND ( [TableName_NameEn] like ISNULL(@TableName_NameEn, [TableName_NameEn]) )
	AND ( [TableName_Search] like ISNULL(@TableName_Search, [TableName_Search]) )*/
END
GO
-- =============================================
